/**
 * 
 */
package com.gxa.ehome.dao.impl;




import com.gxa.ehome.dao.AdminDao;
import com.gxa.ehome.dao.BaseDao;
import com.gxa.ehome.entity.Admin;
import com.gxa.ehome.util.DBUtil;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
//import com.gxa.userManager.entity.*;

/**
 * UserDaoImpl 作为UserDao的实现类
 * 
 * @author bilei
 * @date 2021年3月8日
 */
public class AdminDaoImpl extends BaseDao<Admin> implements AdminDao {

	// 引入DBUtil
	private DBUtil dbutil = new DBUtil();

	@Override
	public Integer insert(Admin admin) throws Exception {
		return super.insert(admin);
	}
	@Override
	public Admin selectByName(String phone) throws Exception {
		String sql = "SELECT *FROM tb_admin WHERE admin_phone=?";
		PreparedStatement preparedStatement = dbutil.getPreparedStatement(sql);
		preparedStatement.setObject(1, phone);
		ResultSet resultSet = dbutil.execQuery(preparedStatement);
		Admin admin = null;
		if (resultSet.next()) {
			admin = new Admin();
			admin.setId(resultSet.getInt(1));// user.setId(resultSet.getInt("id"));
			admin.setName(resultSet.getString(2));
			admin.setPwd(resultSet.getString(3));
			admin.setSalt(resultSet.getString(4));
			admin.setPhone(resultSet.getString(5));
			admin.setReTime(resultSet.getDate(6));
		}
		dbutil.closeAll();
		return admin;
		
	}


}
